﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace WebService.Controllers
{
    public class BaseController : Controller
    {
        /// <summary>
        /// 重写控制器的OnActionExecuting方法,使请求到达到达指定控制器之前进行过滤
        /// </summary>
        /// <param name="filterContext"></param>
        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            base.OnActionExecuting(filterContext);
            if(Session["UserInfo"]==null)
            {
                //请求必须得到一个result的结果才回返回,不然会一直走下去
                filterContext.Result = Redirect("/Login/Index");
            }
        }
    }
}
